import axios from "@/API/axios/axios"
// 老人入住或信息更新
export interface UserInfo {
  baseInfo: {
    name: string;
    gender: string;
    birthDate: Date;
    domicile: string;
    idCard: string;
    height: string;
    weight: string;
    nation: string;
    maritalStatus: string;
  };
  familyMembers: {
    name: string;
    relationship: string;
    phone: string;
  }[];
  healthInfo: {
    diseaseHistory: string;
    healthStatus: string;
  };
  admissionInfo: {
    admissionTime: Date;
    buildingNo: string;
    floorNo: string;
    roomNo: string;
    bedNo: string;
  };
}
// 基本信息
export interface BaseInfo {
  name: string;
  gender: string;
  birthDate: Date;
  domicile: string;
  idCard: string;
  height: string;
  weight: string;
  nation: string;
  maritalStatus: string;
  diseaseHistory: string;
  healthStatus: string;
  admissionTime: Date;
}
// 家属信息数组
export interface FamilyInfo {
  name: string;
  relationship: string;
  phone: string;
}[]
// 床位信息
export interface BedInfo {
  bedNo: string;
  buildingNo: string;
  roomNo: string;
  floorNo: string;
}
export interface CheckInfo {
  baseInfo: BaseInfo;
  familyInfo: FamilyInfo[];
  bedInfo: BedInfo;
  elderId?: string;
}

// 登记老人基本信息API
export function checkInElderApi(checkInfo: CheckInfo) {
  return axios.post('/elder/register', { checkInfo });
}

// 根据Id或者姓名获取老人信息API
export function getElderInfoApi(elderId: String) {
  const params: Record<string, any> = {}; // 声明动态键类型
  if (elderId) {
    params['elderId'] = elderId;
  }
  return axios.get('/elder/getElderInfo', {
    params
  });
}

// 根据id修改老人信息API
export function updateElderInfoApi(elderInfo: CheckInfo) {
  return axios.post('/elder/updateElderInfo', elderInfo);
}
// 删除老人信息
export function deleteElderInfoApi(elderId: string) {
  return axios.delete('/elder/deleteElderInfo', {
    params: { elderId }
  });
}